<?php
/**
 * @authors alex (20779512@qq.com)
 * @date    2014-03-24 16:49:33
 * @version 1.0
 */

class CommentAction extends HomeAction {

    //商品详细信息
    public function index(){
        $id = I('get.id');
        $map['id']=$id;
        $list = M('Goods')->where($map)->find();
        if (!$list) {
            $this->error('没有该商品');
        }

        $this->assign('list',$list);

        //商品规格
        if ($list['hasoption']==1) {
            unset($map);
            $map['goodsid']=$list['id'];
            $specs=M("GoodsSpec")->where($map)->order("displayorder asc,id asc")->select();
            foreach($specs as $key=>$val){
                unset($map);
                $map['specid']=$val['id'];
                $specs[$key]['items']=M("GoodsSpecItem")->where($map)->order("displayorder asc,id asc")->select();   
            }
            unset($map);
            $map['goodsid']=$list['id'];
            $options=M("GoodsOption")->where($map)->order("displayorder asc,id asc")->select();
            $this->assign('options',$options);            
            $this->assign('specs',$specs);
        }

        //评论
        unset($map);
        $map['pid']=$id;
        $comment = M("Comment")->where($map)->order('id desc')->select();
        $this->assign('comment',$comment);
        $commentNum = M("Comment")->where($map)->count();
        $this->assign('commentNum',$commentNum);
    	$this->display();
    }


    public function nosay(){
        $map['memberID'] = $this->_user['memberID'];
        $map['payStatus'] = 1;
        $map['del'] = 0;
        $order_no = M('Order')->where($map)->getField('id,order_no');

        unset($map);
        $map['order_no'] = array('in',$order_no);
        $map['comment'] = 0;
        $list= M('OrderDetail')->where($map)->select();
        $this->assign('list', $list);

        $this->display();
    }

}